﻿#include "windowdelegate.h"
#include "include/views/cef_browser_view.h"
#include "include/views/cef_window.h"
void WindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window)
{
    window->AddChildView(browser_view_);
    window->Show();
    browser_view_->RequestFocus();
    window->SetTitle(L"这是我的窗口标题");

}
void WindowDelegate::OnWindowDestroyed(CefRefPtr<CefWindow> window)
{
    browser_view_ = nullptr;
    CefQuitMessageLoop();
}
CefRect WindowDelegate::GetInitialBounds(CefRefPtr<CefWindow> window)
{
    CefRefPtr<CefDisplay> display = CefDisplay::GetPrimaryDisplay();
    CefRect rect = display->GetBounds();
    rect.x = (rect.width - 800) / 2;
    rect.y = (rect.height - 600) / 2;
    rect.width = 800;
    rect.height = 600;
    return rect;
}